package com.google.code.customercare.model.ext;

import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;



public class MyUserDao {

	private static Logger log = Logger.getLogger("customercare-model");
	
	@SuppressWarnings("rawtypes")
	public List findByUserNameAndPasswd(String username, String passwd) {
		List list = null;
		try{
			HibernateUtil.beginTransaction();
			Session s = HibernateUtil.getSession();
			String hsql = "from User model where model.username = :username and passwd = :passwd";
			Query queryObj = s.createQuery(hsql);
			queryObj.setParameter("username", username);
			queryObj.setParameter("passwd", passwd);
			list = queryObj.list();
			HibernateUtil.commitTransaction();
		}catch(Exception e){
			try {
				HibernateUtil.rollbackTransaction();
			} catch (Exception e1) {
				log.error("Rollback fail", e1);
			}
			log.error("Error", e);
		}
		return list;
	}
}
